package com.logicalthinking.socialmall.controller.admin;

import com.github.chenlijia1111.utils.common.Result;
import com.github.chenlijia1111.utils.core.annos.PropertyCheck;
import com.logicalthinking.socialmall.biz.MallProductBiz;
import com.logicalthinking.socialmall.common.vo.requestVo.product.AdminProductQueryParams;
import com.logicalthinking.socialmall.common.vo.responseVo.product.AdminProductListVo;
import com.logicalthinking.socialmall.common.vo.responseVo.product.SocialAdminProductVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 产品控制器
 *
 * @author Chen LiJia
 * @since 2020/2/18
 */
@RestController(value = "adminProductController")
@RequestMapping(value = "admin/product")
@Api(tags = "产品")
@PropertyCheck
public class ProductController {


    @Autowired
    private MallProductBiz biz;//产品

    /**
     * 后台查询商品列表
     *
     * @return
     */
    @GetMapping(value = "listPage")
    @ApiOperation(value = "商品列表查询", response = AdminProductListVo.class)
    public Result adminListPage(AdminProductQueryParams params) {
        Result result = biz.adminListPage(params);
        return result;
    }

    /**
     * 查询商品详情
     *
     * @param productId
     * @return
     */
    @GetMapping(value = "findById")
    @ApiOperation(value = "查询商品详情", response = SocialAdminProductVo.class)
    public Result adminFindInfoById(String productId) {
        return biz.adminFindInfoById(productId);
    }

    /**
     * 上架
     *
     * @param productId
     * @return
     */
    @PostMapping(value = "shelf/up")
    @ApiOperation(value = "上架")
    public Result shelfUp(String productId) {
        return biz.shelfUp(productId);
    }

    /**
     * 批量上架
     *
     * @param productIdList
     * @return
     */
    @PostMapping(value = "shelf/up/batch")
    @ApiOperation(value = "批量上架")
    public Result batchShelfUp(List<String> productIdList) {
        return biz.batchShelfUp(productIdList);
    }

    /**
     * 下架
     *
     * @param productId
     * @return
     */
    @PostMapping(value = "shelf/down")
    @ApiOperation(value = "下架")
    public Result shelfDown(String productId) {
        return biz.shelfDown(productId);
    }

    /**
     * 批量下架
     *
     * @param productIdList
     * @return
     */
    @PostMapping(value = "shelf/down/batch")
    @ApiOperation(value = "批量下架")
    public Result batchShelfDown(List<String> productIdList) {
        return biz.batchShelfDown(productIdList);
    }

    /**
     * 删除
     *
     * @param productId
     * @return
     */
    @PostMapping(value = "delete")
    @ApiOperation(value = "删除")
    public Result delete(String productId) {
        return biz.delete(productId);
    }

    /**
     * 批量删除
     *
     * @param productIdList
     * @return
     */
    @PostMapping(value = "delete/batch")
    @ApiOperation(value = "批量删除")
    public Result batchDelete(List<String> productIdList) {
        return biz.batchDelete(productIdList);
    }

}
